package cn.zj.admin.modules.issues.bean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xi.yang
 * @create 2020-12-15 19:46
 **/
public class TableData<T> {
    private int code;
    private String msg;
    private long count;
    private List<T> data = new ArrayList<>();

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public static TableDataBuilder builder() {
        return new TableDataBuilder();
    }
    public static final class TableDataBuilder<T> {
        private int code;
        private String msg;
        private long count;

        private List<T> data = new ArrayList<>();

        private TableDataBuilder() {
        }

        public TableDataBuilder code(int code) {
            this.code = code;
            return this;
        }

        public TableDataBuilder msg(String msg) {
            this.msg = msg;
            return this;
        }

        public TableDataBuilder count(long count) {
            this.count = count;
            return this;
        }

        public TableDataBuilder data(List<T> data) {
            this.data = data;
            return this;
        }

        public TableData build() {
            TableData tableData = new TableData();
            tableData.setCode(code);
            tableData.setMsg(msg);
            tableData.setCount(count);
            tableData.setData(data);
            return tableData;
        }
    }
}
